import BaseMock from '@/mock/BaseMock'
const MockBase = require('mockjs')

export default class loginMock extends BaseMock {
  constructor (Mock) {
    let authMock = function (index) {
      return MockBase.mock(projAccountInfoList[index])
    }
    let subSys = 'cpe'
    let moduleName = 'login'
    super(1,
      authMock,
      function (item, params) {
        if (!item.delStatus) {
          return false
        }
        var filterField = [
          {
            name: 'capitalIntegrationName',
            filterType: 'like'
          },
          {
            name: 'assetCode',
            filterType: 'eq'
          }]
        var rs = true
        if (params) {
          filterField.forEach(filter => {
            if (params[filter.name] && filter.filterType === 'like' && item[filter.name].indexOf(params[filter.name]) < 0) {
              rs = false
            } else if (params[filter.name] && filter.filterType === 'eq' && item[filter.name] !== params[filter.name]) {
              rs = false
            }
          })
        }
        return rs
      },
      subSys,
      moduleName,
      Mock,
      [],
      'keyId'
    )
  }
}

const projAccountInfoList = [
  {
    keyId: '1',
    assetCode: 'ZC001',
    capitalIntegrationName: '项目公司名称1',
    // 合同名称
    htName: '01建设工程01公司',
    delStatus: true,
    houseNum: '房号',
    accountReceivableJe: '应收账款金额'
  }
]
